package com.feicheng.iou.controller.common;

import com.feicheng.iou.commom.ReturnCode;
import com.feicheng.iou.entity.ReservationTry;
import com.feicheng.iou.exception.SystemException;
import com.feicheng.iou.result.ResultInfo;
import com.feicheng.iou.service.ReservationTryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wuweinan
 * @since 2021-06-28
 */
@RestController
@RequestMapping("/iou/common")
@Slf4j
public class ReservationTryCommonController {

    @Autowired
    private ReservationTryService reservationTryService; //预约试听实现类

    /**
     * @Author wuweinan
     * @Description 添加试听信息接口
     * @Date 2021-6-29 17:19
     * @param reservationTry
     * @return ResultInfo
     */
    @PutMapping("/try")
    public ResultInfo addTryTime(ReservationTry reservationTry) {
        log.info("ReservationTryCommonController的addTryTime进入");

        //检验参数是否为空
        if (reservationTry == null) {
            throw new SystemException(ReturnCode.PARAM_NOT_NULL);
        }

        log.info("ReservationTryCommonController的addTryTime返回");

        return reservationTryService.updateTryReservationTime(reservationTry);
    }
}
